package com.example.executordemo;

import android.app.IntentService;
import android.content.Intent;
import android.os.SystemClock;
import android.support.annotation.Nullable;
import android.util.Log;

/**
 * Created by tangjiangxu on 11/1/17.
 */

public class LocalIntentService extends IntentService {
    private static final String TAG = "LocalIntentService";
    public LocalIntentService() {
        super(TAG);
        Log.e(TAG, "LocalIntentService: thread name:" + Thread.currentThread().getName());
    }

    @Override
    protected void onHandleIntent(@Nullable Intent intent) {
        Log.e(TAG, "onHandleIntent: thread name:" + Thread.currentThread().getName());
        String action = intent.getStringExtra("task_action");
        Log.d(TAG, "onHandleIntent: action1:" + action);
        SystemClock.sleep(3000);
        Log.d(TAG, "onHandleIntent: action2:" + action);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.e(TAG, "onDestroy: ");
    }
}
